<?php
class Upload extends CI_Controller {

    function Upload()
    {
        parent::__construct();
        $this->load->helper(array('form','url','file'));
        
    
    }
    
    function index()
    {
        
        $this->load->view('upload_form', array('error' => ' ' ));
        
    }

    function picupload()
    {

        //Load Model
        $this->load->model('Process_image');

        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '2048'; //2 meg


		$i=0;

        $this->load->library('upload');

        foreach($_FILES as $key => $value)
        {
			$i++;
            if( ! empty($key['name']))
            {
                $this->upload->initialize($config);
        
                if ( ! $this->upload->do_upload($key))
                {
                    $errors[] = $this->upload->display_errors();
                    
                }    
                else
                {

                    $this->Process_image->process_pic();

                }
             }
        
        }
        
	
        
        $data['success'] = 'Thank You, Files Upladed!';

        $this->load->view('upload_success', $data); //Picture Upload View

        
        
        
    } 
}
?>